package com.github.duanmujava;

/**
 * 线程基础练习
 * Date: 2017-03-04
 *
 * @author duanzhengqiang
 */
public class BaseConcurrency {

    public static void main(String[] args) {
        //创建线程的方式一：直接继承Thread类
        //任务一
        new Thread() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    System.out.println("Task 1 => " + i);
                }
            }
        }.start();
        //任务二
        new Thread() {
            @Override
            public void run() {
                for (int j = 0; j < 100; j++) {
                    System.out.println("Task 2 => " + j);
                }
            }
        }.start();
        //结果：发现Task 1 和 Task 2 交替执行
    }
}
